<template>
  <footer class="site-footer">
    <div class="footer-container">
      <div class="footer-top">
        <!-- 关于我们区块 -->
        <div class="footer-column about-column">
          <h3 class="footer-heading">关于我们</h3>
          <p class="footer-description">
            这是一个基于Vue和SpringBoot的CMS系统，提供内容管理功能。
          </p>
          <div class="social-media">
            <a href="#" class="social-icon" aria-label="微信"><span class="icon-wechat"></span></a>
            <a href="#" class="social-icon" aria-label="微博"><span class="icon-weibo"></span></a>
            <a href="#" class="social-icon" aria-label="抖音"><span class="icon-douyin"></span></a>
          </div>
        </div>
        
        <!-- 快速链接区块 -->
        <div class="footer-column links-column">
          <h3 class="footer-heading">快速链接</h3>
          <ul class="footer-links">
            <li class="footer-link-item">
              <router-link to="/" class="footer-link">首页</router-link>
            </li>
            <li 
              v-for="category in footerCategories" 
              :key="category.categoryId" 
              class="footer-link-item"
            >
              <router-link 
                :to="`/category/${category.categoryId}`" 
                class="footer-link"
              >
                {{ category.categoryName }}
              </router-link>
            </li>
            <li class="footer-link-item">
              <router-link to="/sitemap" class="footer-link">网站地图</router-link>
            </li>
          </ul>
        </div>
        
        <!-- 联系我们区块 -->
        <div class="footer-column contact-column">
          <h3 class="footer-heading">联系我们</h3>
          <address class="contact-info">
            <p class="contact-item">
              <span class="contact-icon icon-email"></span>
              <span>邮箱: contact@example.com</span>
            </p>
            <p class="contact-item">
              <span class="contact-icon icon-phone"></span>
              <span>电话: 123-456-7890</span>
            </p>
            <p class="contact-item">
              <span class="contact-icon icon-location"></span>
              <span>地址: 北京市海淀区科技园路88号</span>
            </p>
          </address>
          
          <div class="newsletter">
            <h4 class="newsletter-title">订阅我们的新闻</h4>
            <form class="newsletter-form">
              <input 
                type="email" 
                placeholder="请输入您的邮箱" 
                class="newsletter-input"
                required
              >
              <button type="submit" class="newsletter-button">订阅</button>
            </form>
          </div>
        </div>
      </div>
      
      <!-- 版权信息 -->
      <div class="footer-bottom">
        <div class="copyright">
          <p>&copy; {{ currentYear }} CMS系统. 保留所有权利.</p>
        </div>
        <div class="footer-legal-links">
          <router-link to="/privacy" class="legal-link">隐私政策</router-link>
          <router-link to="/terms" class="legal-link">服务条款</router-link>
          <router-link to="/disclaimer" class="legal-link">免责声明</router-link>
        </div>
      </div>
    </div>
  </footer>
</template>

<script>
import { getCategoryList } from '@/api/category'

export default {
  name: 'SiteFooter',
  data() {
    return {
      footerCategories: [],
      currentYear: new Date().getFullYear()
    }
  },
  created() {
    this.fetchFooterCategories()
  },
  methods: {
    async fetchFooterCategories() {
      try {
        const res = await getCategoryList({ 
          visible: '0', 
          status: '0', 
          size: 5 
        })
        this.footerCategories = res.data
      } catch (error) {
        console.error('获取底部栏目失败:', error)
        this.$notify.error({
          title: '错误',
          message: '获取栏目信息失败，请稍后再试'
        })
      }
    }
  }
}
</script>

<style>
.site-footer {
  background-color: #222;
  color: #bbb;
  padding: 40px 0 20px;
  font-size: 14px;
  line-height: 1.6;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 30px;
}

.footer-column {
  flex: 1;
  min-width: 250px;
  margin-bottom: 20px;
  padding: 0 15px;
}

.footer-column.contact-column {
  flex: 1.5;
}

.footer-heading {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  position: relative;
  padding-bottom: 10px;
}

.footer-heading::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 2px;
  background-color: #4CAF50;
}

.footer-description {
  margin-bottom: 15px;
}

.social-media {
  display: flex;
  gap: 15px;
}

.social-icon {
  color: #bbb;
  font-size: 20px;
  transition: color 0.3s;
  display: inline-block;
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
}

.social-icon:hover {
  color: #4CAF50;
  background-color: rgba(76, 175, 80, 0.2);
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-link-item {
  margin-bottom: 10px;
}

.footer-link {
  color: #bbb;
  text-decoration: none;
  transition: all 0.3s;
  display: inline-block;
}

.footer-link:hover {
  color: #4CAF50;
  padding-left: 5px;
}

.contact-info {
  font-style: normal;
  margin: 0;
  padding: 0;
}

.contact-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.contact-icon {
  margin-right: 10px;
  color: #4CAF50;
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.newsletter {
  margin-top: 20px;
}

.newsletter-title {
  color: #fff;
  font-size: 16px;
  margin-bottom: 15px;
}

.newsletter-form {
  display: flex;
}

.newsletter-input {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 4px 0 0 4px;
  font-size: 14px;
  outline: none;
}

.newsletter-button {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  transition: background-color 0.3s;
}

.newsletter-button:hover {
  background-color: #45a049;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid #444;
}

.copyright {
  margin-bottom: 10px;
}

.footer-legal-links {
  display: flex;
  gap: 15px;
}

.legal-link {
  color: #bbb;
  text-decoration: none;
  transition: color 0.3s;
}

.legal-link:hover {
  color: #4CAF50;
}

@media (max-width: 768px) {
  .footer-top {
    flex-direction: column;
  }
  
  .footer-column {
    margin-bottom: 30px;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-legal-links {
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
  }
}

@media (max-width: 576px) {
  .newsletter-form {
    flex-direction: column;
  }
  
  .newsletter-input {
    border-radius: 4px;
    margin-bottom: 10px;
  }
  
  .newsletter-button {
    border-radius: 4px;
    width: 100%;
  }
}
</style>